<template>
    <div class="info-tool">
        <div class="little-helper" v-drag v-show="showLittleHelper">
            <div class="head can-drag">
                <img src="@/assets/images/kwt.png" class="can-drag" draggable="false"/>
                <p class="can-drag">康卫通首页智能质控小助手</p>
                <div @click="showLittleHelperPop"><i class="el-icon-arrow-down down-btn"></i></div>
            </div>
            <div class="drg-content">
                <el-collapse v-model="activeCollapse" accordion
                             v-if="JSON.stringify(infoData.DRGsData) !== '{}' && infoData.DRGsData">
                    <el-collapse-item name="1">
                        <template slot="title">付费方式：{{infoData.YLFKFS}} {{checkCodeText('ylfkfs',
                            infoData.YLFKFS)}}<br/>DRG分组：{{infoData.DRGsData.code}}
                        </template>
                        <p>DRG名称：{{infoData.DRGsData.name}}
                            <span class="refresh-btn" @click="refreshDRG()"><svg-icon icon-class="refresh"/>重试</span>
                        </p>
                        <p>DRG权重：{{infoData.DRGsData.weight}}</p>
                        <p class="income">预计盈亏：
                            <span style="margin-right: 20px">{{infoData.DRGsData.drgIncome | getMoneyNum}}元</span>
                            高低倍率：<span :class="infoData.DRGsData.lowMagnification ? 'span-blue':'span-red'" v-if="infoData.DRGsData.lowMagnification || infoData.DRGsData.highMagnification">
                                {{infoData.DRGsData.lowMagnification || infoData.DRGsData.highMagnification}}
                                {{infoData.DRGsData.lowMagnification ? '低' : '高'}}
                                <i :class="infoData.DRGsData.lowMagnification ? 'el-icon-bottom':'el-icon-top'"/>
                            </span>
                            <span v-else>正常</span>
                        </p>
                    </el-collapse-item>
                </el-collapse>
                <el-collapse v-model="activeCollapse" accordion v-else>
                    <el-collapse-item name="1">
                        <template slot="title">DRG分组：</template>
                        <p>DRG名称：
                            <span class="refresh-btn" @click="refreshDRG()"><svg-icon icon-class="refresh"/>重试</span>
                        </p>
                        <p>DRG权重：</p>
                        <p class="income">预计盈亏：
                            <span>元</span>
                        </p>
                    </el-collapse-item>
                </el-collapse>
            </div>
            <div class="scroe">
                <div>
                    <p><span>{{infoData.nationScore || 0}}</span>分</p>
                    <p>国标得分</p>
                </div>
                <div>
                    <p><span>{{-infoData.hospitalScore || 0}}</span>分</p>
                    <p>院标扣分</p>
                </div>
                <span class="icd" @click="openICDPop">ICD</span>
            </div>
            <div class="helper-content">
                <el-tabs v-model="activeHelper" stretch>
                    <el-tab-pane :label="getTabsTitle('coding')" name="coding">
                        <div class="scroll-box" v-show="!infoData.noQC">
                            <el-row class="scroll-row-title">
                                <el-col :span="24"><span class="block"></span>强制缺陷(<span>{{infoData.codingError.length}}</span>)
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row" v-for="(item, index) in infoData.codingError"
                                    :key="'forced' + index">
                                <el-col :span="18">
                                    {{item.fieldName}}：{{item.content}}
                                </el-col>
                                <el-col :span="4" v-if="item.nationDeduction > 0">
                                    <span class="score-row">{{-item.nationDeduction}}分</span>
                                </el-col>
                                <el-col :span="24">
                                    提示：
                                    <template v-for="(it, i) in item.msg">
                                        <span class="normal" :key="'forcedTips' + i" v-if="item.msg.length > 1">
                                            {{i + 1}}.{{it}};<br/>
                                        </span>
                                        <span class="normal" :key="'forcedTips' + i" v-else>{{it}};</span>
                                    </template>
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row-title">
                                <el-col :span="24"><span class="block doubt"></span>疑似缺陷(<span>{{infoData.codingWaring.length}}</span>)
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row" v-for="(item, index) in infoData.codingWaring"
                                    :key="'suspected' + index">
                                <el-col :span="18">
                                    {{item.fieldName}}：{{item.content}}
                                </el-col>
                                <el-col :span="4" v-if="item.nationDeduction > 0">
                                    <span class="score-row">{{-item.nationDeduction}}分</span>
                                </el-col>
                                <el-col :span="24">
                                    提示：
                                    <template v-for="(it, i) in item.msg">
                                        <span class="normal" :key="'suspectedTips' + i" v-if="item.msg.length > 1">
                                            {{i + 1}}.{{it}};<br/>
                                        </span>
                                        <span class="normal" :key="'suspectedTips' + i" v-else>{{it}};</span>
                                    </template>
                                </el-col>
                                <el-col :span="2" :offset="19" v-if="!item.isIgnored">
                                    <el-button class="ignore" size="mini" type="primary" plain
                                               @click="ignore(item.id, 'coding')">
                                        忽略
                                    </el-button>
                                </el-col>
                                <el-col :span="10" :offset="14" v-else-if="item.isIgnored">
                                    <el-row>
                                        <el-col class="ignored" :span="10">
                                            <span>已忽略</span>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-button size="mini" plain type="warning"
                                                       @click="cancelIgnore(item.id, 'coding')">
                                                取消忽略
                                            </el-button>
                                        </el-col>
                                    </el-row>
                                </el-col>
                            </el-row>
                        </div>
                        <div class="tryQC" v-show="infoData.noQC">
                            <svg-icon class="noqcicon" icon-class="noqc" @click="reQC()"/>
                            <p @click="reQC()">质控失败,点击重试</p>
                            <el-button type="primary" @click="reQC()">质控</el-button>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane :label="getTabsTitle('notCoding')" name="notCoding">
                        <div class="scroll-box" v-show="!infoData.noQC">
                            <el-row class="scroll-row-title">
                                <el-col :span="24"><span class="block"></span>强制缺陷(<span>{{infoData.noneCodingError.length}}</span>)
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row" v-for="(item, index) in infoData.noneCodingError"
                                    :key="'notForced' + index">
                                <el-col :span="18">
                                    {{item.fieldName}}：{{item.content}}
                                </el-col>
                                <el-col :span="4" v-if="item.nationDeduction > 0">
                                    <span class="score-row">{{-item.nationDeduction}}分</span>
                                </el-col>
                                <el-col :span="24">
                                    提示：
                                    <template v-for="(it, i) in item.msg">
                                        <span class="normal" :key="'notForcedTips' + i" v-if="item.msg.length > 1">
                                            {{i + 1}}.{{it}};<br/>
                                        </span>
                                        <span class="normal" :key="'notForcedTips' + i" v-else>{{it}};</span>
                                    </template>
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row-title">
                                <el-col :span="24"><span class="block doubt"></span>疑似缺陷(<span>{{infoData.noneCodingWaring.length}}</span>)
                                </el-col>
                            </el-row>
                            <el-row class="scroll-row" v-for="(item, index) in infoData.noneCodingWaring"
                                    :key="'notSuspected' + index">
                                <el-col :span="18">
                                    {{item.fieldName}}：{{item.content}}
                                </el-col>
                                <el-col :span="4" v-if="item.nationDeduction > 0">
                                    <span class="score-row">{{-item.nationDeduction}}分</span>
                                </el-col>
                                <el-col :span="24">
                                    提示：
                                    <template v-for="(it, i) in item.msg">
                                        <span class="normal" :key="'notSuspectedTips' + i" v-if="item.msg.length > 1">
                                            {{i + 1}}.{{it}};<br/>
                                        </span>
                                        <span class="normal" :key="'notSuspectedTips' + i" v-else>{{it}};</span>
                                    </template>
                                </el-col>
                                <el-col :span="2" :offset="19" v-if="!item.isIgnored">
                                    <el-button class="ignore" size="mini" type="primary" plain
                                               @click="ignore(item.id, 'notCoding')">
                                        忽略
                                    </el-button>
                                </el-col>
                                <el-col :span="10" :offset="14" v-else-if="item.isIgnored">
                                    <el-row>
                                        <el-col class="ignored" :span="10">
                                            <span>已忽略</span>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-button size="mini" plain type="warning"
                                                       @click="cancelIgnore(item.id, 'notCoding')">
                                                取消忽略
                                            </el-button>
                                        </el-col>
                                    </el-row>
                                </el-col>
                            </el-row>
                        </div>
                        <div class="tryQC" v-show="infoData.noQC">
                            <svg-icon class="noqcicon" icon-class="noqc" @click="reQC()"/>
                            <p @click="reQC()">质控失败,点击重试</p>
                            <el-button type="primary" @click="reQC()">质控</el-button>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane :label="getTabsTitle('score')" name="score">
                        <div class="scroll-box" v-show="!infoData.noQC">
                            <el-row class="scroll-row" v-for="(item, index) in infoData.allDeduction"
                                    :key="'score' + index">
                                <el-col :span="18">
                                    {{item.fieldName}}：{{item.content}}
                                </el-col>
                                <el-col :span="4">
                                    <span class="score-row">{{-item.nationDeduction}}分</span>
                                </el-col>
                                <el-col :span="24">
                                    提示：
                                    <template v-for="(it,i) in item.msg">
                                        <span class="normal" :key="'scoreTips' + i" v-if="item.msg.length > 1">
                                            {{i + 1}}.{{it}};<br/>
                                        </span>
                                        <span class="normal" :key="'scoreTips' + i" v-else>{{it}};</span>
                                    </template>
                                </el-col>
                            </el-row>
                        </div>
                        <div class="tryQC" v-show="infoData.noQC">
                            <svg-icon class="noqcicon" icon-class="noqc" @click="reQC()"/>
                            <p @click="reQC()">质控失败,点击重试</p>
                            <el-button type="primary" @click="reQC()">质控</el-button>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </div>
            <div class="feedback">
                <!--<el-button type="text" icon="el-icon-edit-outline" v-auth="{code: 300009000001}"-->
                           <!--@click="showDialogFeedback">意见反馈-->
                <!--</el-button>-->
            </div>
            <div class="top-line"></div>
            <div class="right-line"></div>
            <div class="bottom-line"></div>
            <div class="left-line"></div>
        </div>
        <div class="little-helper small" v-show="!showLittleHelper">
            <div class="head">
                <img src="@/assets/images/kwt.png" draggable="false"/>
                <p>首页智能质控小助手(<span>{{infoData.nationScore}}分</span>)</p>
                <div @click="showLittleHelperPop"><i class="el-icon-arrow-up up-btn"></i></div>
            </div>
        </div>
        <el-dialog title="意见反馈"
                   :close-on-click-modal="false"
                   :visible.sync="isShowFeedback"
                   @close="closeDialogFeedback"
                   center
                   width="600px">
            <el-form :model="feedbackForm" :rules="rules" ref="feedbackForm" label-width="80px"
                     class="feedback-ruleForm">
                <el-form-item label="反馈类型" prop="feedbackKind">
                    <el-select v-model="feedbackForm.feedbackKind" filterable placeholder="请选择反馈类型" size="small">
                        <el-option
                            v-for="item in typeOptions"
                            :key="item.key"
                            :label="item.value"
                            :value="item.key">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="反馈内容" prop="content">
                    <el-input v-model="feedbackForm.content" size="small" placeholder="请输入反馈内容" type="textarea"
                              :rows="3"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button size="small" @click="closeDialogFeedback">取 消</el-button>
                <el-button size="small" @click="submitFeedback" type="primary">确 定</el-button>
            </div>
        </el-dialog>
        <div class="searchICD" v-drag v-show="showICD">
            <div class="head can-drag">
                <img src="@/assets/images/kwt.png" class="can-drag" draggable="false"/>
                <p class="can-drag">ICD编码查询</p>
                <div @click="closeICDPop"><i class="el-icon-close down-btn"></i></div>
            </div>
            <div class="icd-content">
                <div class="search-pag" v-show="!showICDSearchRes">
                    <el-radio-group v-model="searchICD.typeYB" class="typeYB-choose">
                        <el-radio-button label="国临版2.0"></el-radio-button>
                        <el-radio-button label="医保版1.0"></el-radio-button>
                    </el-radio-group>
                    <el-radio-group class="radio-icd-box" v-model="searchICD.type">
                        <el-radio label="ICD-10">ICD-10</el-radio>
                        <el-radio label="ICD-9-CM-3">ICD-9-CM-3</el-radio>
                    </el-radio-group>
                    <el-input size="small" placeholder="请输入疾病名称/编码" v-model="searchICD.word" clearable
                              @keyup.enter.native="submitSearchICD(1)" class="input-with-button">
                        <el-button size="small" slot="append" icon="el-icon-search" @click="submitSearchICD(1)">搜索
                        </el-button>
                    </el-input>
                    <div class="logo-box">
                        <img src="@/assets/images/logo.png"/>
                        <a href="http://www.kwtsoft.com/" target="_blank">康卫通信息科技成都有限公司</a>
                    </div>
                </div>
                <div class="results-page" v-show="showICDSearchRes">
                    <div class="res-head">
                        <el-row class="title">
                            <el-col :span="2">
                                <div @click="closeICDRes">
                                    <i class="el-icon-arrow-left toback"></i>
                                </div>
                            </el-col>
                            <el-col :span="20">
                                版本: {{searchICD.typeYB}} {{searchICD.type}}
                            </el-col>
                        </el-row>
                        <el-input size="small" placeholder="请输入疾病名称/编码" v-model="searchICD.word" clearable
                                  @keyup.enter.native="submitSearchICD(1)" class="input-with-button">
                            <el-button size="small" slot="append" icon="el-icon-search" @click="submitSearchICD(1)">搜索
                            </el-button>
                        </el-input>
                        <el-row class="res-select" v-show="searchICD.type !== 'ICD-10'">
                            <el-col :span="12">
                                <span>类别</span>
                                <el-select v-model="searchICD.category" filterable @change="submitSearchICD(1)"
                                           class="res-category" size="small">
                                    <el-option key="1" label="全部" value="all"></el-option>
                                    <el-option key="2" label="手术" value="手术"></el-option>
                                    <el-option key="3" label="治疗性操作" value="治疗性操作"></el-option>
                                    <el-option key="4" label="诊断性操作" value="诊断性操作"></el-option>
                                    <el-option key="5" label="介入治疗" value="介入治疗"></el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="12">
                                <span>录入选项</span>
                                <el-select v-model="searchICD.selectivity" filterable @change="submitSearchICD(1)"
                                           class="res-selectivity" size="small">
                                    <el-option key="6" label="全部" value="all"></el-option>
                                    <el-option key="7" label="必选" value="必选"></el-option>
                                    <el-option key="8" label="选择性" value="选择性"></el-option>
                                    <el-option key="9" label="中医必选" value="中医必选"></el-option>
                                </el-select>
                            </el-col>
                        </el-row>
                    </div>
                    <div class="content-res-icd scroll-content" :class="searchICD.type !== 'ICD-10' ? 'short' : ''"
                         v-show="ICDTotal > 0">
                        <el-row type="flex" justify="space-between" v-for="(item, index) in ICDRes" class="content-row"
                                :key="index">
                            <el-col :span="15" class="name">
                                {{item.diseaseName || item.name}}
                            </el-col>
                            <el-col :span="8" class="code">
                                {{item.fullCode || item.code}}
                            </el-col>
                            <el-col class="type" :span="24" v-show="searchICD.type !== 'ICD-10'">
                                <span>类别：{{item.type}}</span><span>录入选项：{{item.selectively}}</span>
                            </el-col>
                        </el-row>
                    </div>
                    <p v-show="ICDTotal <= 0">抱歉！没有找到符合限定条件的记录。</p>
                    <pagination class="content-pag" v-show="ICDTotal > 0" :isSmall="true"
                                :layout="'total, prev, pager, next'" :total="ICDTotal" :page.sync="currentPageICD"
                                :limit.sync="ICDPageSize"
                                @pagination="submitSearchICD"/>
                </div>
            </div>
            <div class="top-line"></div>
            <div class="right-line"></div>
            <div class="bottom-line"></div>
            <div class="left-line"></div>
        </div>
    </div>
</template>

<script>
    import {
        ignoreData,
        cancelIgnoreData,
        saveFeedback,
        searchICD10,
        searchICD10YB,
        searchICD9,
        searchICD9YB,
        reQCData,
        reDRGSingle
    } from '@/api/medical-records-info/index'
    import nameCoding from '@/assets/json/nameCoding.json'
    import Pagination from '@/components/Pagination'
    import {getMoneyNum} from '@/utils/filters'

    export default {
        name: 'infoTool',
        props: ['infoData'],
        model: {
            prop: 'infoData',
            event: 'changeInfoData'
        },
        data () {
            return {
                // 显示小助手
                showLittleHelper: true,
                // 小助手当前标签
                activeHelper: 'coding',
                // 小助手数据
                helperData: {},
                // 显示意见反馈弹框
                isShowFeedback: false,
                // 显示临床反馈弹框
                isShowMRFeedback: false,
                // 类型选项
                typeOptions: [
                    {'key': 1, 'value': '编码问题'},
                    {'key': 2, 'value': '非编码问题'},
                    {'key': 3, 'value': '评分问题'},
                    {'key': 4, 'value': '统计问题'},
                    {'key': 5, 'value': '其他问题'}
                ],
                // 意见反馈表单
                feedbackForm: {
                    feedbackKind: '',
                    content: ''
                },
                // 临床反馈表单
                MRFeedbackForm: {
                    content: ''
                },
                // buffer列表
                bufferArr: [],
                // 图片列表
                imgList: [],
                // 预览图片路径
                dialogImageUrl: '',
                // 显示预览图片
                dialogImgVisible: false,
                // 评分弹框显示标签页
                activeNameTable: 'index',
                // 显示评分弹框
                isShowScore: false,
                // 评分类型
                scoreType: '1',
                // 评分列表数据
                scoreData: [],
                // 所有的扣分，项包括自动扣分项
                detailIdItem: [],
                // 国标得分
                nationalScore: 0,
                // 院标得分
                hospitalScore: 0,
                // 显示ICD查询
                showICD: false,
                // ICD查询内容
                searchICD: {
                    typeYB: '国临版2.0',
                    type: 'ICD-10',
                    word: '',
                    category: '',
                    selectivity: ''
                },
                // 显示ICD查询结果/查询页面
                showICDSearchRes: false,
                // ICD查询数据
                ICDRes: [],
                // ICD数据总数
                ICDTotal: 0,
                // ICD单页数量
                ICDPageSize: 50,
                // ICD当前页
                currentPageICD: 1,
                userType: '',
                // 计时器
                timer: null,
                // 默认展开DRG
                activeCollapse: '1',
                rules: {
                    feedbackKind: [
                        {required: true, message: '请选择反馈类型', trigger: 'change'}
                    ],
                    content: [
                        {required: true, message: '请输入反馈内容', trigger: ['blur', 'change']}
                    ]
                }
            }
        },
        directives: {
            drag (el) {
                el.onmousedown = function (e) {
                    if (e.target.className.includes('can-drag')) {
                        let disx = e.pageX - el.offsetLeft
                        let disy = e.pageY - el.offsetTop
                        document.onmousemove = function (e) {
                            el.style.left = e.pageX - disx + 'px'
                            el.style.top = e.pageY - disy + 'px'
                        }
                        document.onmouseup = function () {
                            document.onmousemove = document.onmouseup = null
                        }
                    }
                    let targetDivWidth = el.offsetWidth
                    let targetDivHeight = el.offsetHeight
                    let targetDivLeft = el.offsetLeft
                    let targetDivTop = el.offsetTop
                    if (e.target.className === 'top-line') {
                        let startY = e.clientY
                        document.onmousemove = function (e) {
                            let distY = Math.abs(e.clientY - startY)
                            if (e.clientY < startY) {
                                el.style.height = targetDivHeight + distY + 'px'
                                el.style.top = targetDivTop - distY + 'px'
                            } else {
                                el.style.height = targetDivHeight - distY + 'px'
                                el.style.top = targetDivTop + distY + 'px'
                            }
                            if (el.className === 'little-helper') {
                                if (document.getElementsByClassName('scroll-box').length) {
                                    let DRGHeight = document.getElementsByClassName('drg-content')[0].scrollHeight
                                    document.getElementsByClassName('scroll-box')[0].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                    document.getElementsByClassName('scroll-box')[1].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                    document.getElementsByClassName('scroll-box')[2].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                }
                            } else if (el.className === 'searchICD') {
                                if (document.getElementsByClassName('res-select')[0].offsetHeight) {
                                    document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(el.style.height) - 162 - 42 + 'px'
                                } else {
                                    document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(el.style.height) - 162 + 'px'
                                }
                            }
                        }
                        document.onmouseup = function () {
                            document.onmousemove = document.onmouseup = null
                        }
                    }
                    if (e.target.className === 'bottom-line') {
                        let startY = e.clientY
                        document.onmousemove = function (e) {
                            let distY = Math.abs(e.clientY - startY)
                            if (e.clientY < startY) {
                                el.style.height = targetDivHeight - distY + 'px'
                            } else {
                                el.style.height = targetDivHeight + distY + 'px'
                            }
                            if (el.className === 'little-helper') {
                                if (document.getElementsByClassName('scroll-box').length) {
                                    let DRGHeight = document.getElementsByClassName('drg-content')[0].scrollHeight
                                    document.getElementsByClassName('scroll-box')[0].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                    document.getElementsByClassName('scroll-box')[1].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                    document.getElementsByClassName('scroll-box')[2].style.maxHeight = parseInt(el.style.height) - 174 - DRGHeight + 'px'
                                }
                            } else if (el.className === 'searchICD') {
                                if (document.getElementsByClassName('res-select')[0].offsetHeight) {
                                    document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(el.style.height) - 162 - 42 + 'px'
                                } else {
                                    document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(el.style.height) - 162 + 'px'
                                }
                            }
                        }
                        document.onmouseup = function () {
                            document.onmousemove = document.onmouseup = null
                        }
                    }
                    if (e.target.className === 'left-line') {
                        let startX = e.clientX
                        document.onmousemove = function (e) {
                            let distX = Math.abs(e.clientX - startX)
                            if (e.clientX < startX) {
                                el.style.width = targetDivWidth + distX + 'px'
                                el.style.left = targetDivLeft - distX + 'px'
                            } else {
                                el.style.width = targetDivWidth - distX + 'px'
                                el.style.left = targetDivLeft + distX + 'px'
                            }
                        }
                        document.onmouseup = function () {
                            document.onmousemove = document.onmouseup = null
                        }
                    }
                    if (e.target.className === 'right-line') {
                        let startX = e.clientX
                        document.onmousemove = function (e) {
                            let distX = Math.abs(e.clientX - startX)
                            if (e.clientX < startX) {
                                el.style.width = targetDivWidth - distX + 'px'
                            } else {
                                el.style.width = targetDivWidth + distX + 'px'
                            }
                        }
                        document.onmouseup = function () {
                            document.onmousemove = document.onmouseup = null
                        }
                    }
                }
            }
        },
        created () {
            this.userType = localStorage.getItem('userType').toString()
        },
        mounted () {
            this.timer = setInterval(this.collapseDrg, 10)
        },
        methods: {
            /**
             * 显示隐藏小助手
             */
            showLittleHelperPop () {
                this.showLittleHelper = !this.showLittleHelper
            },
            /**
             * 获取小助手数据
             */
            getHelperData () {
                this.nationalScore = this.infoData.nationScore || 0
                this.hospitalScore = this.infoData.hospitalScore || 0
            },
            /**
             * 获取标签页名称
             * @param name 标签名
             */
            getTabsTitle (name) {
                switch (name) {
                case 'score':
                    return this.infoData.nationScore ? `扣分(${this.infoData.nationScore - 100})分` : '扣分(0分)'
                case 'coding':
                    return this.infoData.coding ? `编码缺陷(${this.infoData.coding})处` : '编码缺陷(0)处'
                case 'notCoding':
                    return this.infoData.noneCoding ? `非编码缺陷(${this.infoData.noneCoding})处` : '非编码缺陷(0)处'
                }
            },
            /**
             * 忽略
             * @param id 数据id
             * @param name 数据类型
             */
            ignore (id, name) {
                let params = {id}
                ignoreData(params).then(res => {
                    if (res.code.toString() === '200') {
                        let infoData = this.infoData
                        if (name === 'coding') {
                            for (let i = 0; i < infoData.codingWaring.length; i++) {
                                if (infoData.codingWaring[i].id === id) {
                                    infoData.codingWaring[i].isIgnored = true
                                    break
                                }
                            }
                        } else if (name === 'notCoding') {
                            for (let i = 0; i < infoData.noneCodingWaring.length; i++) {
                                if (infoData.noneCodingWaring[i].id === id) {
                                    infoData.noneCodingWaring[i].isIgnored = true
                                    break
                                }
                            }
                        }
                        this.$emit('changeInfoData', infoData)
                        this.$message.success('忽略成功!')
                    } else {
                        this.$message.error(res.message)
                    }
                })
            },
            /**
             * 取消忽略
             * @param id 数据id
             * @param name 数据类型
             */
            cancelIgnore (id, name) {
                let params = {id}
                cancelIgnoreData(params).then(res => {
                    if (res.code.toString() === '200') {
                        let infoData = this.infoData
                        if (name === 'coding') {
                            for (let i = 0; i < infoData.codingWaring.length; i++) {
                                if (infoData.codingWaring[i].id === id) {
                                    infoData.codingWaring[i].isIgnored = false
                                    break
                                }
                            }
                        } else if (name === 'notCoding') {
                            for (let i = 0; i < infoData.noneCodingWaring.length; i++) {
                                if (infoData.noneCodingWaring[i].id === id) {
                                    infoData.noneCodingWaring[i].isIgnored = false
                                    break
                                }
                            }
                        }
                        this.$emit('changeInfoData', infoData)
                        this.$message.success('成功取消忽略!')
                    } else {
                        this.$message.error(res.message)
                    }
                })
            },
            /**
             * 打开意见反馈弹框
             */
            showDialogFeedback () {
                this.isShowFeedback = true
            },
            /**
             * 关闭意见反馈弹框
             */
            closeDialogFeedback () {
                this.$refs['feedbackForm'].resetFields()
                this.isShowFeedback = false
            },
            /**
             * 提交意见反馈表单
             */
            submitFeedback () {
                this.$refs['feedbackForm'].validate((valid) => {
                    if (valid) {
                        let params = this.feedbackForm
                        saveFeedback(params).then(res => {
                            if (res.code.toString() === '200') {
                                this.$message.success('提交意见反馈成功!')
                                this.closeDialogFeedback()
                            } else {
                                this.$message.error(res.message)
                            }
                        })
                    } else {
                        return false
                    }
                })
            },
            /**
             * 打开ICD查询
             */
            openICDPop () {
                this.searchICD.typeYB = '国临版2.0'
                this.searchICD.type = 'ICD-10'
                this.searchICD.word = ''
                this.searchICD.category = 'all'
                this.searchICD.selectivity = 'all'
                this.ICDRes = []
                this.ICDTotal = 0
                this.showICDSearchRes = false
                this.showICD = true
            },
            /**
             * 关闭ICD查询
             */
            closeICDPop () {
                this.ICDRes = []
                this.ICDTotal = 0
                this.showICDSearchRes = false
                this.showICD = false
            },
            /**
             * 查询ICD
             * @param page 指定页数/重新输入查询
             */
            submitSearchICD (page) {
                let params = {
                    keyWord: this.searchICD.word,
                    pageCount: this.ICDPageSize,
                    pageIndex: typeof page === 'object' ? page.page : page
                }
                if (this.searchICD.typeYB === '国临版2.0') {
                    if (this.searchICD.type === 'ICD-10') {
                        searchICD10(params).then(res => {
                            this.ICDRes = res.data.rows
                            this.ICDTotal = Number(res.data.total)
                            this.showICDSearchRes = true
                            let allHeight = document.getElementsByClassName('searchICD')[0].offsetHeight
                            document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(allHeight) - 162 + 'px'
                        })
                    } else {
                        params.type = this.searchICD.category === 'all' ? '' : this.searchICD.category
                        params.selectivity = this.searchICD.selectivity === 'all' ? '' : this.searchICD.selectivity
                        searchICD9(params).then(res => {
                            this.ICDRes = res.data.rows
                            this.ICDTotal = Number(res.data.total)
                            this.showICDSearchRes = true
                            let allHeight = document.getElementsByClassName('searchICD')[0].offsetHeight
                            document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(allHeight) - 162 - 42 + 'px'
                        })
                    }
                } else {
                    if (this.searchICD.type === 'ICD-10') {
                        searchICD10YB(params).then(res => {
                            this.ICDRes = res.data.rows
                            this.ICDTotal = Number(res.data.total)
                            this.showICDSearchRes = true
                            let allHeight = document.getElementsByClassName('searchICD')[0].offsetHeight
                            document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(allHeight) - 162 + 'px'
                        })
                    } else {
                        params.type = this.searchICD.category === 'all' ? '' : this.searchICD.category
                        params.selectivity = this.searchICD.selectivity === 'all' ? '' : this.searchICD.selectivity
                        searchICD9YB(params).then(res => {
                            this.ICDRes = res.data.rows
                            this.ICDTotal = Number(res.data.total)
                            this.showICDSearchRes = true
                            let allHeight = document.getElementsByClassName('searchICD')[0].offsetHeight
                            document.getElementsByClassName('content-res-icd')[0].style.maxHeight = parseInt(allHeight) - 162 - 42 + 'px'
                        })
                    }
                }
            },
            /**
             * 关闭ICD结果页面返回第一个页面
             */
            closeICDRes () {
                this.searchICD.category = 'all'
                this.searchICD.selectivity = 'all'
                this.showICDSearchRes = false
            },
            /**
             * 打开关闭drg信息
             */
            collapseDrg () {
                // 174 = 其他元素高度154 + drg信息框的margin20
                let DRGHeight = document.getElementsByClassName('drg-content')[0].offsetHeight
                let maxHeight = document.getElementsByClassName('little-helper')[0].offsetHeight - 174 - DRGHeight + 'px'
                document.getElementsByClassName('scroll-box')[0].style.maxHeight = maxHeight
                document.getElementsByClassName('scroll-box')[1].style.maxHeight = maxHeight
                document.getElementsByClassName('scroll-box')[2].style.maxHeight = maxHeight
            },
            /**
             * 重新质控
             */
            reQC () {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                let params = {
                    medicalRecordSign: this.infoData.medicalRecordSign,
                    hospitalTime: Number(this.infoData.ZYCS),
                    orgId: query.orgId
                }
                reQCData(params).then(res => {
                    if (res.code.toString() === '200') {
                        let data = res.data
                        if (!data.medicalRecordID) delete data.medicalRecordID
                        let infoData = {
                            ...this.infoData,
                            ...data
                        }
                        this.$emit('changeInfoData', infoData)
                        this.getHelperData()
                    }
                })
            },
            /**
             * 重试DRG
             */
            refreshDRG () {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                let params = {
                    medicalRecordSign: this.infoData.medicalRecordSign,
                    hospitalTime: Number(this.infoData.ZYCS),
                    isLast: true,
                    orgId: query.orgId
                }
                reDRGSingle(params).then(res => {
                    if (res.code.toString() === '200') {
                        let data = res.data
                        if (!data.medicalRecordID) data.medicalRecordID = params.medicalRecordID
                        this.$emit('changeInfoData', {...this.infoData, DRGsData: data})
                    }
                })
            },
            /**
             * 获取需转码数据
             * @param code 类型值
             * @param val 数据参数
             */
            checkCodeText (code, val) {
                return nameCoding[code] ? nameCoding[code][val] || val : val
            }
        },
        filters: {
            getMoneyNum
        },
        components: {
            Pagination
        },
        beforeDestroy () {
            clearInterval(this.timer)
        }
    }
</script>

<style scoped lang="scss">
    .little-helper, .searchICD {
        position: fixed;
        z-index: 1999;
        right: 10px;
        bottom: 10px;
        background: #fff;
        color: #333;
        width: 350px;
        height: 520px;
        line-height: 22px;
        font-size: 14px;
        overflow: hidden;
        border: 1px solid #dcdcdc;
        border-radius: 4px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        box-shadow: 0 0 8px #b1b1b1;
        .head {
            height: 38px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            padding: 5px;
            background: #f2f2f2;
            position: relative;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            img {
                display: block;
                width: 26px;
            }
            p {
                font-weight: 600;
                font-size: 16px;
                margin: 0 0 0 10px;
                span {
                    color: #409eff;
                }
            }
            div {
                width: 38px;
                height: 38px;
                position: absolute;
                right: 0;
                top: 0;
                cursor: pointer;
                .down-btn, .up-btn {
                    position: absolute;
                    top: 9px;
                    right: 9px;
                    color: #409eff;
                    font-size: 20px;
                }
            }
        }
        &.small {
            height: 38px;
        }
        .scroe {
            position: relative;
            margin-bottom: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            div {
                margin-right: 10px;
                &:nth-child(1) {
                    margin-right: 20px;
                }
                &:nth-child(2) {
                    span {
                        color: #F59A23;
                    }
                }
                p {
                    font-size: 14px;
                    text-align: center;
                    margin: 0;
                    line-height: 20px;
                    span {
                        font-size: 24px;
                        font-weight: 600;
                        color: #409eff;
                    }
                }
            }
            .icd {
                position: absolute;
                left: 70%;
                top: 13px;
                font-size: 12px;
                line-height: 12px;
                padding: 2px;
                border-radius: 4px;
                color: #409eff;
                border: 1px solid #409eff;
                cursor: pointer;
            }
        }
        .helper-content {
            padding: 0 5px;
            .scroll-box {
                height: auto;
                max-height: 306px;
                overflow-y: auto;
                .scroll-row {
                    padding: 0 4px;
                    background: #f2f2f2;
                    font-weight: 600;
                    margin-bottom: 6px;
                    line-height: 18px;
                    .score-row {
                        width: 100%;
                        display: block;
                        color: #e21f06;
                        text-align: right;
                    }
                }
                .scroll-row-title {
                    padding: 0 4px;
                    font-weight: 600;
                    margin-bottom: 6px;
                    line-height: 18px;
                    .block {
                        display: inline-block;
                        width: 4px;
                        height: 12px;
                        background: #ec3434;
                        border-radius: 2px;
                        margin-right: 4px;
                        &.doubt {
                            background: #ec7534;
                        }
                    }
                    .span {
                        color: #ec3434;
                        &.doubt {
                            color: #ec7534;
                        }
                    }
                }
                .ignored {
                    padding-top: 5px;
                    span {
                        color: #e6a23c;
                    }
                }
            }
            .tryQC {
                .noqcicon {
                    display: block;
                    width: 90px;
                    height: 90px;
                    margin: 10px auto 10px;
                    cursor: pointer;
                }
                p {
                    text-align: center;
                    font-size: 14px;
                    margin: 0;
                    cursor: pointer;
                }
                button {
                    display: block;
                    width: 80px;
                    margin: 10px auto;
                }
            }
        }
        .feedback {
            width: 100%;
            position: absolute;
            bottom: 0;
            left: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            &.between {
                padding: 0 5px;
                justify-content: space-between;
            }
        }
        .top-line {
            position: absolute;
            top: -2px;
            left: 0;
            height: 6px;
            width: 100%;
            background: transparent;
            cursor: n-resize;
        }
        .right-line {
            position: absolute;
            top: 0;
            right: -2px;
            height: 100%;
            width: 6px;
            background: transparent;
            cursor: e-resize;
        }
        .bottom-line {
            position: absolute;
            bottom: -2px;
            left: 0;
            height: 6px;
            width: 100%;
            background: transparent;
            cursor: n-resize;
        }
        .left-line {
            position: absolute;
            top: 0;
            left: -2px;
            height: 100%;
            width: 6px;
            background: transparent;
            cursor: e-resize;
        }
    }

    .searchICD {
        right: 364px;
    }

    /deep/ .el-tabs__item {
        padding: 0 6px;
    }

    .dialog-footer {
        text-align: center;
    }

    .searchICD {
        .icd-content {
            .search-pag {
                padding: 5px 5px 0 5px;
                .typeYB-choose {
                    display: flex;
                    justify-content: center;
                    margin: 30px 0;
                    /deep/.el-radio-button__inner {
                        padding: 20px 40px;
                    }
                }
                .radio-icd-box {
                    width: 100%;
                    text-align: center;
                    margin-bottom: 20px;
                }
                .logo-box {
                    margin-top: 170px;
                    text-align: center;
                    img {
                        display: block;
                        width: 100px;
                        margin: 0 auto;
                    }
                    a {
                        color: #409EFF;
                        &:hover {
                            color: #409EFF;
                        }
                    }
                }
            }
            .results-page {
                padding: 0 5px;
                .res-head {
                    .title {
                        margin: 0 0 10px 0;
                        line-height: 22px;
                        .toback {
                            font-size: 18px;
                            margin-top: 2px;
                            cursor: pointer;
                        }
                    }
                    .res-select {
                        margin-top: 10px;
                        .res-category {
                            width: 114px;
                        }
                        .res-selectivity {
                            width: 100px;
                        }
                    }
                }
                .content-res-icd {
                    margin-top: 5px;
                    height: auto;
                    max-height: 360px;
                    overflow-y: auto;
                    &.short {
                        max-height: 318px;
                    }
                    .content-row {
                        padding: 2px 0;
                        border-bottom: 1px solid #eee;
                        flex-wrap: wrap;
                        &:last-child {
                        }
                        .name, .code {
                            font-size: 14px;
                            font-weight: 600;
                        }
                        .code {
                            box-sizing: border-box;
                            padding-right: 8px;
                            word-break: break-all;
                        }
                        .type {
                            margin: 0;
                            span:first-child {
                                margin-right: 10px;
                            }
                        }
                    }
                }
                .content-pag {
                    margin-top: 10px;
                    padding: 0;
                    /deep/ .pagination {
                        text-align: center;
                        .el-pagination__total {
                            font-size: 12px;
                        }
                    }
                }
            }
        }
    }

    .drg-content {
        margin: 10px;
        padding: 10px;
        background: #F5F6FA;
        border-radius: 4px;
        /deep/ .el-collapse {
            border: 0;
            .el-collapse-item {
                .el-collapse-item__header {
                    background: #F5F6FA;
                    line-height: 18px;
                    height: auto;
                    border: 0;
                }
                .el-collapse-item__content {
                    background: #F5F6FA;
                    padding-bottom: 0;
                    p {
                        line-height: 18px;
                        margin: 0;
                    }
                }
                .el-collapse-item__wrap {
                    border: 0;
                }
            }
            .income {
                span {
                    .el-icon-top {
                        color: #ee3934;
                    }
                    .el-icon-bottom {
                        color: #1682e6;
                    }
                    &.span-blue {
                        color: #1682e6;
                    }
                    &.span-red {
                        color: #ee3934;
                    }
                }
            }
        }
    }

    .refresh-btn {
        margin-left: 6px;
        font-size: 13px;
        color: #1682e6;
        height: 18px;
        cursor: pointer;
        white-space: nowrap;
        svg {
            width: 14px;
            height: 14px;
            margin-bottom: -2px;
        }
    }
</style>
<style lang="scss">
    .score-dialog {
        width: 80%;
        margin-top: 8vh !important;
        .el-dialog__title {
            font-weight: 600;
        }
        .el-dialog__body {
            padding: 15px 20px 20px;
        }
        .el-radio-group {
            width: 100%;
            text-align: right;
        }
        .score-table {
            .rating-items {
                width: 6px;
                height: 12px;
                display: inline-block;
                vertical-align: middle;
                margin: 0;
                border-radius: 2px;
                &.blue {
                    background: #1297dc;
                }
                &.yellow {
                    background: #f29716;
                }
            }
        }
        .dialog-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            .footer-score-box {
                width: 50%;
                p {
                    margin: 0;
                    font-weight: 500;
                }
                span:first-child {
                    font-size: 24px;
                }
                .national {
                    color: #66a0f2;
                }
                .hospital {
                    color: #ff8100;
                }
                .deduction {
                    color: #e21f06;
                }
            }
        }
    }

    .normal {
        font-weight: normal;
    }

    .upload-img {
        max-height: 159px;
        overflow: hidden;
        &.none {
            & > .el-upload.el-upload--picture-card {
                display: none;
            }
        }
    }
</style>
